package com.yi.mall.order.service.impl;

import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
import com.baomidou.mybatisplus.extension.conditions.update.LambdaUpdateChainWrapper;
import com.yi.mall.common.model.OrderDetail;
import com.yi.mall.order.mapper.OrderDetailMapper;
import com.yi.mall.order.service.IOrderDetailService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 订单中所包含的商品 服务实现类
 * </p>
 *
 * @author zzy
 * @since 2025-07-28
 */
@Service
public class OrderDetailServiceImpl extends ServiceImpl<OrderDetailMapper, OrderDetail> implements IOrderDetailService {

    @Override
    public List<OrderDetail> listByOrderId(String orderId) {
        LambdaQueryChainWrapper<OrderDetail> query = new LambdaQueryChainWrapper<>(this.getBaseMapper());
        List<OrderDetail> list = query.eq(OrderDetail::getOrderId, orderId).list();
        return list;
    }

    @Override
    public List<OrderDetail> listByOrderIds(List<String> orderId) {
        LambdaQueryChainWrapper<OrderDetail> query = new LambdaQueryChainWrapper<>(this.getBaseMapper());
        List<OrderDetail> list = query.in(OrderDetail::getOrderId, orderId).list();
        return list;
    }
    @Override
    public void removeByOrderId(Long id) {
        LambdaUpdateChainWrapper<OrderDetail> updateChainWrapper = new LambdaUpdateChainWrapper<>(baseMapper);
        updateChainWrapper.eq(OrderDetail::getOrderId,id).remove();
    }
}
